package sky.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sky.dao.TicketDAO;
import sky.domain.Flight;
import sky.domain.Ticket;
import sky.service.TicketService;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Gauss
 * Date: 24.04.13
 * Time: 17:39
 * To change this template use File | Settings | File Templates.
 */
@Service
public class TicketServiceImpl implements TicketService{

    @Autowired
    private TicketDAO ticketDAO;

    @Override
    @Transactional
    public void addTicket(Ticket ticket) {
        ticketDAO.addTicket(ticket);
    }

    @Override
    @Transactional
    public List<Ticket> listTicket() {
        return ticketDAO.listTicket();
    }

    @Override
    @Transactional
    public void removeTicket(Integer id) {
        ticketDAO.removeTicket(id);
    }

    @Override
    @Transactional
    public List<Ticket> getFreeTicketsByFlight(Integer id) {
        return ticketDAO.getFreeTicketsByFlight(id);
    }

    @Override
    @Transactional
    public void bookTicketByPlace(Integer id, Integer row, Character place, Integer userId) {
        ticketDAO.bookTicketByPlace(id, row, place, userId);
    }

    @Override
    @Transactional
    public void addTickets(Flight flight) {
        ticketDAO.addTickets(flight);
    }

    @Override
    @Transactional
    public List<Character> getFreePlaces(Integer flightId) {
        return ticketDAO.getFreePlaces(flightId);
    }

    @Override
    @Transactional
    public List<Character> getFreePlacesOnRow(Integer flightId, Integer row) {
        return ticketDAO.getFreePlacesOnRow(flightId, row);
    }

    @Override
    @Transactional
    public List<Integer> getFreeRowsOnPlace(Integer flightId, Character place) {
        return ticketDAO.getFreeRowsOnPlace(flightId, place);
    }

    @Override
    @Transactional
    public List<Integer> getFreeRows(Integer flightId) {
        return ticketDAO.getFreeRows(flightId);
    }
}
